﻿<%@ Page Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true" CodeBehind="Detail.aspx.cs"
    Inherits="ProjectQuaDep.Detail" %>

<%@ Register Src="Control/BoxTinTuc.ascx" TagName="BoxTinTuc" TagPrefix="uc3" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <style>
        .link-chiase4room
        {
            margin-top: 10px;
            margin-bottom: 10px;
        }
        .link-chiase4room input
        {
            border: 1px solid #999;
            width: 100%;
            padding: 3px;
            margin-top: 5px;
            color: #333;
            font-style: italic;
        }
    </style>
    <div>
        <div class="detail-imgbig">
            <div class="detail-img">
                <img src="<%=linkImgBig %>" />
                <div class="xyshortcontent">
                    <p style="font-size: 19px; font-weight: bold;">
                        <%=ShortContent %>
                    </p>
                </div>
                <div class="detail-img-rl">
                    <a href="<%=linkRL %>">
                        <img src="/Images/icon/row-detaill.png" />
                    </a>
                </div>
                <div class="detail-img-rr">
                    <a href="<%=linkRR %>">
                        <img src="/Images/icon/row-detailr.png" />
                    </a>
                </div>
                <div class="bg-detail-imgbig">
                    <h1>
                        <%=NameBig %>(<%=sn%>)
                    </h1>
                    <div class="bg-detail-imgbig-vote">
                        <iframe src="//www.facebook.com/plugins/like.php?href=<%=linkCm %>&amp;width=100&amp;height=21&amp;colorscheme=light&amp;layout=button_count&amp;action=like&amp;show_faces=true&amp;send=false&amp;appId=313386658769610"
                            scrolling="no" frameborder="0" style="border: none; overflow: hidden; width: 100px;
                            height: 21px;" allowtransparency="true"></iframe>
                        <%--<img src="/images/web/like.gif" />--%>
                    </div>
                    <div class="bg-detail-imgbig-vote">
                        <p>
                            <span id="detailcomment"></span>
                        </p>
                        <a href="#divComment"><b>
                            <img src="/images/web/comment.gif" /></b></a>
                    </div>
                    <div class="bg-detail-imgbig-vote">
                        <p>
                            <span id="detailshare"></span>
                        </p>
                        <a href="https://www.facebook.com/sharer/sharer.php?u=<%=linkCm %>" target="_blank">
                            <b>
                                <img src="/images/web/share.gif" /></b></a>
                    </div>
                    <div class="bg-detail-imgbig-vote">
                        <p>
                            <span class="showvote">
                                <%=vote %></span></p>
                        <a href="javascript:void(0)" onclick="UpdateVoteByID_Hung(<%=id %>,'showvote')"><b>
                            <img src="/images/web/vote.gif" /></b></a>
                    </div>
                </div>
            </div>
            <div class="detail-img-other">
                <% if (dtDetail.Rows.Count > 0)
                   {
                       string linkChannel = BO.Utils.BuildLinkDetail(NameBig, imageid, "0"); %>
                <div class="detail-img-other-small">
                    <a href="<%=linkChannel %>">
                        <img src="<%=dtDetail.Rows[0][BO.Const.tbImages.ImgThumb].ToString() %>" />
                    </a>
                </div>
                <% } %>
                <% if (dtOther.Rows.Count > 0)
                   {
                       for (int i = 0; i < dtOther.Rows.Count; i++)
                       {
                           string linkImgThub = dtOther.Rows[i][BO.Const.tbImages.ImgThumb].ToString();
                           //string linkChannel = BO.Utils.BuildLinkDetail(NameBig, imageid, (i + 1).ToString());
                           string linkChannel = BO.Utils.BuildLinkDetail(NameBig, imageid, (i + 1).ToString());
                           string addClass = " last";
                           if (i < (dtOther.Rows.Count - 1)) { addClass = ""; }
                           else
                           { if (dtOther.Rows.Count < 7) addClass = ""; }
                           //them cai nay de hien ra nhieu neu k co thi thoi di
                           //--------------------------------------------
                           string addStyle = " style=\"display:none\"";
                           int idNum = int.Parse(index);
                           //if (i > 6)
                           //{
                               //if (idNum >= 7)
                               //{
                               //    addStyle = "";
                               //}
                               //else
                               //{
                               //    addStyle = " style=\"display:none\"";
                               //}
                               if (idNum < 7 && i<7)
                               {
                                   addStyle = "";
                               }
                               else if (idNum >= 7 && idNum < 15)
                               {
                                   if (i < 15)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 15 && idNum < 23)
                               {
                                   if (i < 23)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 23 && idNum < 31)
                               {
                                   if (i < 31)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 31 && idNum < 39)
                               {
                                   if (i < 39)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 39 && idNum < 47)
                               {
                                   if (i < 47)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 39 && idNum < 47)
                               {
                                   if (i < 47)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 47 && idNum < 55)
                               {
                                   if (i < 55)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 55 && idNum < 63)
                               {
                                   if (i < 62)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 63 && idNum < 71)
                               {
                                   if (i < 71)
                                   {
                                       addStyle = "";
                                   }
                               }
                               else if (idNum >= 71 && idNum < 79)
                               {
                                   if (i < 79)
                                   {
                                       addStyle = "";
                                   }
                               }
                           //}
                           //----------------------------
                           if (i == 6 || i == 14 || i == 22 || i == 30 || i == 38 || i == 46 || i == 54 || i == 62 || i == 70 || i == 78)
                           {
                               addClass = " last";
                           }
                           else
                           {
                               addClass = "";
                           }
                           
                         
                %>
                <div class="detail-img-other-small<%=addClass %>" <%=addStyle %>>
                    <a href="<%=linkChannel %>">
                        <img src="<%=linkImgThub %>" />
                    </a>
                </div>
                <% }
                   } %>
                <div class="clear">
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div class="fl w700 mgt10">
            <div class="loadallfb" id="LoadCm">
                <div class="vote-detail">
                    <a target="_blank" href="https://www.facebook.com/conyeu.yeucon">
                        <img src="/Images/vote-detail.png" /></a>
                </div>
                <div class="link-chiase4room">
                    <b>Link chia sẻ:</b><br />
                    <input value="<%=linkCm %>" />
                </div>
                <div style="float: left; width: 580px;">
                    <div class="fb-like" data-href="<%=linkCm %>" data-width="The pixel width of the plugin"
                        data-height="The pixel height of the plugin" data-colorscheme="light" data-layout="standard"
                        data-action="like" data-show-faces="false" data-send="false">
                    </div>
                </div>
                <div style="float: right">
                    <span style="font-size: 14px; padding-top: 1px; padding-right: 4px; float: left;"
                        id="detailshare-link"></span><a href="https://www.facebook.com/sharer/sharer.php?u=<%=linkCm %>"
                            target="_blank">
                            <img style="float: right" src="/Images/Web/button-share-facebook.png" /></a>
                </div>
                <br />
                <br />
                <div class="clear">
                    <div class="title-cm-detail">
                        <b><a name="divComment">Bình luận</a></b></div>
                    <div class="fb-comments" data-href="<%=linkCm %>" data-numposts="5" data-width="656">
                    </div>
                </div>
            </div>
        </div>
        <div class="fl w300">
            <uc3:BoxTinTuc ID="BoxTinTuc1" runat="server" />
        </div>
    </div>
    <script type="text/javascript">
        function UpdateAllFacebook() {
            $.ajax({
                type: 'GET',
                url: 'https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,commentsbox_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url=\'<%=linkCm %>\'&format=json',
                async: false,
                jsonpCallback: 'jsonCallback',
                contentType: "application/json",
                dataType: 'jsonp',
                success: function (data) {
                    for (i = 0; i < data.length; i++) {
                        var like = data[i].like_count;
                        var shared = data[i].share_count;
                        //var comment = data[i].comment_count;
                        var comment = data[i].commentsbox_count;
                        if (shared > 0) {
                            $('#detailshare-link').text(shared);
                            $('#detailshare').text(shared);
                        }
                        if (comment > 0)
                            $('#detailcomment').text(comment);

                        //$.get("/Services/UploadAllFB.aspx?like=" + like + "&shared=" + shared + "&comment=" + comment + "&id=<%=id %>", function (result) {
                        // if (result == 1)// alert('ok');
                        //else {
                        //alertInfo('that bai');
                        //}
                        //});
                    }
                },
                error: function (e) {
                    console.log(e.message);
                }
            });
        }
        UpdateAllFacebook();
        function UpdateVote() {
            var id = "<%=id %>";
            var checkCookieCM = getCookie("votedetail" + id);
            if (checkCookieCM != null && checkCookieCM != "") {
                alert('Bạn đã vote ảnh này rồi hãy đợi 15 phút để vote tiếp!');
            }
            else {
                //chua binh luan
                $.get("/Services/UpdateVote.aspx?id=" + id, function (result) {
                    if (result == 0) {
                        alert('Bạn vote thất bại!');
                    }
                    else if
                 (result == 1) {
                        alert('Bạn vote thành công!');
                        var numVote = parseInt($('#showvote').text());
                        $('#showvote').text(numVote + 1);
                        setCookie("votedetail" + id, id, 15);
                    }
                    else {
                        alert('Hiện tai chưa thể vote!');
                    }
                });
            }
        }
    </script>
</asp:Content>
